package com.cqjtu.eecs.controller;


import com.cqjtu.eecs.entity.vo.RouterVo;
import com.cqjtu.eecs.service.IPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.Set;

/**
 * <p>
 * 权限 前端控制器
 * </p>
 *
 * @author     
 * @since 2022-03-04
 */
@RestController
@RequestMapping("/permission")
@Api(tags = "用户权限接口")
public class PermissionController {

    @Autowired
    private IPermissionService permissionService;

    @GetMapping("/router")
    @ApiOperation("获取当前登录用户的权限路由")
    public Set<RouterVo> getUserPermission(Principal principal) {
        if (principal == null)
            return null;
        return permissionService.getUserPermission(principal.getName());
    }
}
